feat: stalign with a fit apply pattern. Also foundation for imputation#1195
feat: stalign with a fit apply pattern. Also foundation for imputation#1195selmanozleyen wants to merge 121 commits into
Conversation
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
…leyen/squidpy into feat/spatial_neighbours
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
| "AlignResult", | ||
| "StitchParams", | ||
| "TilingQCParams", | ||
| "assign_stitch_groups", |
| # element we register a transform on so `output_mode="copy"` leaves the input untouched. | ||
| element = sd_deepcopy(element) | ||
| getattr(out, etype)[name] = element | ||
| set_transformation(element, sd_affine, to_coordinate_system=target_cs) |
There was a problem hiding this comment.
breaks if the element already has a transformation, you need to Sequence them
existing = get_transformation(element, to_coordinate_system=moving_cs)
set_transformation(element, Sequence([existing, sd_affine]), to_coordinate_system=target_cs)
| radius = int(np.ceil(float(np.max(blur_values)) * 4.0)) | ||
| denom = 2.0 * (dx * blur_values * 2.0) ** 2 | ||
|
|
||
| for x_i, y_i in zip(x, y, strict=False): |
There was a problem hiding this comment.
How many points do we have? Should probably rasterize
| p: float = 2.0, | ||
| expand: float = 2.0, | ||
| nt: int = 3, | ||
| niter: int = 5000, |
There was a problem hiding this comment.
Can we do some form of early stopping or do we always have to train for 5k steps? Might be too much/too little depending on data
| return data_ref.tables[ref_key], sdata_query.tables[query_key], sdata_query, query_key | ||
|
|
||
|
|
||
| def get_coords(adata: AnnData, spatial_key: str) -> np.ndarray: |
There was a problem hiding this comment.
Claude:
get_coords materializes coords up to 3× per align() (_io.py:71; called at _api.py:83,84 and again _io.py:97). np.asarray(..., dtype=float) forces a float64 copy each time. Thread the already-computed query_xy into writeback_obs and avoid the forced upcast when the array is already suitable.
| "zarr>=3", | ||
| ] | ||
| optional-dependencies.jax = [ | ||
| "jax", |
There was a problem hiding this comment.
Shouldn't we have some lower bound?
Continuation of #1162